#!/usr/bin/env bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin:/usr/local/git/bin

# ======================================
#
#         本脚本用于MacOS/Linux
#
# ======================================

# update
cd $(dirname $0)
git reset --hard
git pull

if [ ! -d venv ]; then
    echo "没有检测到 venv 目录，正在创建虚拟环境"
    python3 -m venv venv
    source venv/bin/activate
    mirror=https://mirrors.aliyun.com/pypi/simple/
    python3 -m pip install --upgrade pip -i $mirror
    pip install -r requirements.txt -i $mirror
else
    source venv/bin/activate
fi

echo "请选择功能："
select i in "检查打卡" "报名统计" "惜时社" "早起团" "暗香单词" "沁心运动" "短文翻译赛" "读书会" "短文翻译统计" "成员列表"
do
    case $i in
        "检查打卡")
            python3 bin/checkin.py
        ;;
        "报名统计")
            python3 bin/signup.py
        ;;
        "惜时社")
            cd 惜时社/ && python3 bin/main.py
        ;;
        "早起团")
            cd 早起团/ && python3 bin/main.py
        ;;
        "暗香单词")
            cd 暗香单词/ && python3 bin/main.py
        ;;
        "沁心运动")
            cd 沁心运动/ && python3 bin/main.py
        ;;
        "短文翻译赛")
            cd 短文翻译赛/ && python3 bin/main.py
        ;;
        "读书会")
            cd 读书会/ && python3 bin/main.py
        ;;
        "短文翻译统计")
            cd 短文翻译赛/ && python3 bin/statistic.py
        ;;
        "成员列表")
            python3 bin/member_list.py
        ;;
        *)
            echo "输入有误！"
        ;;
    esac
done
